import React, { Suspense } from "react";
import { Redirect } from "react-router-dom";
import { Switch } from "react-router-dom";
import { Route } from "react-router-dom";

import routes from './routes'

export default function RouterComp() {
    return <div>
        <Suspense fallback={<div>加载中</div>}>
            <Switch>
                <Redirect from="/" to="/myhome" exact />
                {
                    routes.map((item, index) => {
                        return <Route path={item.path} key={index} component={item.component} ></Route>
                    })
                }
            </Switch>
        </Suspense>

    </div>
}